package com.zs.myorm.framework.test;

import java.util.List;
import java.util.Properties;

import com.zs.myorm.framework.core.factory.ISqlSessionFactory;
import com.zs.myorm.framework.core.factory.impl.JdbcSqlSessionFactory;
import com.zs.myorm.framework.core.session.ISqlSession;
import com.zs.myorm.framework.test.bean.DemoBean;
import com.zs.myorm.framework.test.mapper.IDemoMapper;

public class DemoTestMain {

	public static void main(String[] args) {
		Properties config = new Properties();
		config.put("driver", "com.mysql.jdbc.Driver");
		config.put("url", "jdbc:mysql://127.0.0.1:3306/test");
		config.put("user", "root");
		config.put("password", "123456");
		ISqlSessionFactory sessionFactory = new JdbcSqlSessionFactory(config);
		ISqlSession session = sessionFactory.getSession();
		IDemoMapper mapper = session.getMapper(IDemoMapper.class);
		List<DemoBean> list = mapper.findAll();
		System.out.println(list.size());
		for(DemoBean d:list) {
			System.out.println(d);
			mapper.remove(d.getId());
		}
		DemoBean d = new DemoBean();
		d.setId(1);
		d.setName("212s");
		mapper.save(d);
		session.close();
	}

}
